/*
 *  dna_keypad.h -- provide dna-system keypad simple implementation.
 *  Now only support single way !!!
 *
 *  ORIGINAL AUTHOR: Xu Chun (chun.xu@broadlink.com.cn)
 *
 *  Copyright (c) 2016 Broadlink Corporation
 */

#ifndef __DNA_KEYPAD_H
#define __DNA_KEYPAD_H

#ifdef __cplusplus
    extern "C" {
#endif

/** @defgroup dna_keypad_enum Enum
  * @{
  */

/** @brief This enum defines trigger mode */
enum {
    DNA_KEYPAD_PUSHDOWN_LOW = 0,                   /**< define keypad pushdown is low level  */
    DNA_KEYPAD_PUSHDOWN_HIGH,                      /**< define keypad pushdown is high level */
};

/** @brief This enum defines pushdown type */
enum {
    DNA_KEYPAD_PUSHDOWN_SHORT = 0,                /**< define keypad pushdown short time  */
    DNA_KEYPAD_PUSHDOWN_LONG,                     /**< define keypad pushdown long time   */

	
    DNA_KEYPAD_PUSHDOWN_MULITPLE = 5,			  /**< define keypad pushdown mulitple times*/
};

/**
  * @}
  */

typedef void (* keypad_pushdown_cb_t)(int type);

/**
 * @brief     This function is used to initialize keypad when the first use.
 * @param[in] pin specifies pin number to init.
 * @param[in] mode Trigger mode
 * @param[in] short_time Short pushdown time (Unit: ms, must upper 10ms)
 * @param[in] long_time Long pushdown time (Unit: ms, must upper 10ms)
 * @param[in] Callback Pushdown callback handler
 * @return  0 SUCCESS
 * @note
 * @warning
 */
int dna_keypad_init(
        int pin, int mode,
        int short_time, int long_time,
        keypad_pushdown_cb_t callback);


/*
	@Param:times: pushdown times,timeout: event timeout limition.
	@Return: DNA_SUCCESS : Catch the action. otherwise: None
	@Warning:It is not thread safe,
			 Only use in app_reset_key_handle
*/
int dna_keypad_event_wakeup(int times,int timeout);


enum
{
    DNA_KEYPAD_TIMESTAMP,
    DNA_KEYPAD_RELEASE,
};

/*
 *  because there is 4th generation keypad requirement which need trigger by time interval.
 *  @param[in] pin: specifies pin number to init.
 *  @param[in] mode: Trigger mode.
 *  @param[in] callback: callback when release keypad, and give the keeping time to user space.
 */
int dna_keypad_difftime_init(int pin, int mode, void (*callback)(unsigned char ctl, unsigned long difftime), int timestamp, ...);


#ifdef __cplusplus
}
#endif

#endif

